package map;

import java.sql.CallableStatement;
import java.sql.Connection;
import java.sql.SQLException;

public class ConfianzaDAO {
	
	public void altaConfianza(String oficina1, String oficina2){
		String spName = "{call dbo.alta_confianza (?,?)}";
		Connection con = new ConfigDAO().getConnection();
		CallableStatement cstmt = null;
		
		try {
			cstmt = con.prepareCall(spName);
			cstmt.setString(1, oficina1);
			cstmt.setString(2, oficina2);
			cstmt.executeUpdate();
			cstmt.getConnection().close();

		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
	}

	public void bajaConfianza(String oficina1, String oficina2){
		String spName = "{call dbo.confianza_deshabilitar (?,?)}";
		Connection con = new ConfigDAO().getConnection();
		CallableStatement cstmt = null;
		
		try {
			cstmt = con.prepareCall(spName);
			cstmt.setString(1, oficina1);
			cstmt.setString(2, oficina2);
			cstmt.executeUpdate();
			cstmt.getConnection().close();

		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
	}
	
	public void confianzaHabilitar(String oficina1, String oficina2){
		String spName = "{call dbo.alta_confianza (?,?)}";
		Connection con = new ConfigDAO().getConnection();
		CallableStatement cstmt = null;
		
		try {
			cstmt = con.prepareCall(spName);
			cstmt.setString(1, oficina1);
			cstmt.setString(2, oficina2);
			cstmt.executeUpdate();
			cstmt.getConnection().close();

		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
	}
	
}
